﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace Surveillance
{
    public class Door : Switchable
    {
        #region Door declarations

        public static Texture2D doorTexture;
        private bool isOpen;
        private Rectangle targetLocation;
        private Rectangle initalLocation;

        #endregion

        #region Door constructors

        public Door(Rectangle location)
        {
            isOpen = false;
            targetLocation = location;
            initalLocation = location;
        }

        #endregion

        #region Door public functions


        /* mode:
        * 0 - toggle
        * 1 - off
        * 2- on
        */
        public override void doSwitch(int mode)
        {
            switch (mode)
            {
                case 0: isOpen = !isOpen; break;
                case 1: isOpen = false; break;
                case 2: isOpen = true; break;
            }
        }

        public void reset()
        {
            isOpen = false;
            targetLocation = initalLocation;
        }

        #endregion

        #region Door update and draw

        public void Draw(SpriteBatch spriteBatch)
        {
            if (isOpen)
            {
                return;
            }
            spriteBatch.Draw(doorTexture, targetLocation, Color.White);
        }

        #endregion

        #region Door properties

        public bool IsOpen
        {
            get { return isOpen; }
            set { isOpen = value; }
        }

        public Rectangle TargetLocation
        {
            get { return targetLocation; }
            set { targetLocation = value; }
        }

        #endregion

        
    }

}